'use strict';

const Controller = require('egg').Controller;

let fruitList = [
    "香蕉",
    "苹果",
    "鸭梨",
]
class FruitsController extends Controller {
  async index(){
    this.ctx.body = fruitList
  }

  async create(){
    let fruit = this.ctx.request.body.fruit;
    fruitList.push(fruit)
    this.ctx.body = true
  }

  async destory(){
    let id = this.ctx.params.id;
    fruitList.splice(id,1);
    this.ctx.body = true
  }
}

module.exports = FruitsController;
